<?php
function ConnectToDatabase2()
{	
	require_once('db_login.php');
	return ConnectToDatabase($db_host,$db_username,$db_password,$db_database);
}

function ConnectToDatabase($serverLocation, $username, $password, $database)
{
	$link = mysql_connect($serverLocation, $username, $password);
	if (!$link) 
	{
	    die('Could not connect: ' . mysql_error());
	}
	
	$db_selected = mysql_select_db($database, $link);
	if (!$db_selected) 
	{
	    die ('Can\'t connect to database ' . $database . ': ' . mysql_error());
	}
	return $link;
}

function RunSql($sql, $link)
{
	$result = mysql_query($sql, $link);
	
	if (!$result) 
	{
	    echo "DB Error, could not query the database\n";
	    echo 'MySQL Error: ' . mysql_error();
	    exit;
	}
	return $result;
}
?>